package com.scorpio.framework.interceptor;

import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * 统一地，对返回消息进行加密
 *
 * @package: com.i2f.training.common.converter
 * @author:
 * @date: 2020/3/6 12:39
 */
@Component
public class MessageConverter extends MappingJackson2HttpMessageConverter {

    @Override
    /** Spring在返回JSON数据时通过此方法将Object转为JSON字符串并写出到Response中，针对于@ResponseBody注解生效 */
    protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
        super.writeInternal(object, type, outputMessage);
    }

}
